package easy;

public class Solution_1154 {

    private int[] m = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    public int dayOfYear(String date) {
        String[] split = date.split("-");
        int year = Integer.parseInt(split[0]);
        int month = Integer.parseInt(split[1]);
        int day = Integer.parseInt(split[2]);
        int count = 0;
        for (int i = 0; i < month - 1; i++) {
            count += m[i];
        }
        count += day;
        if (month > 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)) {
            count++;
        }
        return count;
    }

    public static void main(String[] args) {
        Solution_1154 model = new Solution_1154();
        System.out.println(model.dayOfYear("2012-01-02"));
        System.out.println(model.dayOfYear("2019-01-09"));
        System.out.println(model.dayOfYear("2019-02-10"));
        System.out.println(model.dayOfYear("2003-03-01"));
        System.out.println(model.dayOfYear("2004-03-01"));
        System.out.println(model.dayOfYear("2100-03-01"));
    }
}
